﻿@model OrderModel
@{
    //page title
    ViewBag.Title = T("Admin.Orders.EditOrderDetails").Text;
}
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "order-form" }))
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-sales.png")" alt="" />
            @T("Admin.Orders.EditOrderDetails") - @Model.Id @Html.ActionLink("(" + T("Admin.Orders.BackToList") + ")", "List")
        </div>
        <div class="options">
            @if (!Model.IsLoggedInAsVendor)
            {
                <a href="@Url.Action("PdfInvoice", new { orderId = Model.Id })" class="k-button">@T("Admin.Orders.PdfInvoice")</a>
            }
            @if (!Model.IsLoggedInAsVendor)
            {
                <span id="order-delete" class="k-button">@T("Admin.Common.Delete")</span>
            }
            <input type="submit" id="btnRefreshPage" name="btnRefreshPage" style="display: none" />
            <script type="text/javascript">
                $(document).ready(function () {
                    $('#btnRefreshPage').click(function () {
                        //refresh page
                        location.reload();
                    });
                });
            </script>
        </div>
    </div>
    
    @Html.ValidationSummary(false)

    <div id="order-edit">
        <ul>
            <li @Html.RenderSelectedTabIndex(0, GetSelectedTabIndex())>
                @T("Admin.Orders.Info")
            </li>
            <li @Html.RenderSelectedTabIndex(1, GetSelectedTabIndex())>
                @T("Admin.Orders.BillingInfo")
            </li>
            <li @Html.RenderSelectedTabIndex(2, GetSelectedTabIndex())>
                @T("Admin.Orders.ShippingInfo")
            </li>
            <li @Html.RenderSelectedTabIndex(3, GetSelectedTabIndex())>
                @T("Admin.Orders.Products")
            </li>
            @if (!Model.IsLoggedInAsVendor)
            {
                <li @Html.RenderSelectedTabIndex(4, GetSelectedTabIndex())>
                    @T("Admin.Orders.OrderNotes")
                </li>
            }
        </ul>
        <div>
            @TabInfo()
        </div>
        <div>
            @TabBillingInfo()
        </div>
        <div>
            @TabShippingInfo()
        </div>
        <div>
            @TabProducts()
        </div>
        @if (!Model.IsLoggedInAsVendor)
        {
            <div>
                @TabOrderNotes()
            </div>
        }
    </div>
    <script>
        $(document).ready(function() {
            $("#order-edit").kendoTabStrip({
                animation:  {
                    open: {
                        effects: "fadeIn"
                    }
                },
                select: tabstrip_on_tab_select
            });
        });
    </script>

    {
        //custom tabs
        var eventMessage = new AdminTabStripCreated(this.Html, "order-edit");
        EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
        foreach (var eventBlock in eventMessage.BlocksToRender)
        {
            @eventBlock
        }
    }


    @*save selected tab index*@
	<input type="hidden" id="selected-tab-index" name="selected-tab-index" value="@(GetSelectedTabIndex())">

}
@Html.DeleteConfirmation("order-delete")
@helper TabInfo()
{
    @Html.Partial("_OrderDetails.Info", Model)
}
@helper TabBillingInfo()
{
    @Html.Partial("_OrderDetails.Billing", Model)
}
@helper TabShippingInfo()
{
    @Html.Partial("_OrderDetails.Shipping", Model)
}
@helper TabProducts()
{
    @Html.Partial("_OrderDetails.Products", Model)
}
@helper TabOrderNotes()
{
    @Html.Partial("_OrderDetails.Notes", Model)
}
